OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [nanox/] [nxdraw.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
/*
2
 * Copyright (c) 2000 Greg Haerr <greg@censoft.com>
3
 *
4
 * Nano-X Draw Library
5
 */
6
#define MWINCLUDECOLORS
7
#include <stdio.h>
8
#include "nano-X.h"
9
#include "nxdraw.h"
10
 
11
void
12
nxPaintNCArea(GR_DRAW_ID id, int w, int h, GR_CHAR *title, GR_BOOL active,
13
        GR_WM_PROPS props)
14
{
15
        int             x = 0;
16
        int             y = 0;
17
        GR_GC_ID        gc = GrNewGC();
18
        GR_FONT_ID      fontid;
19
        GR_RECT         r;
20
 
21
 
22
        if (props & GR_WM_PROPS_APPFRAME) {
23
                /* draw 2-line 3d border around window*/
24
                nxDraw3dOutset(id, x, y, w, h);
25
                x += 2; y += 2; w -= 4; h -= 4;
26
 
27
                /* draw 1-line inset inside border*/
28
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
29
                GrRect(id, gc, x, y, w, h);
30
                x += 1; y += 1; w -= 2; h -= 2;
31
        } else if (props & GR_WM_PROPS_BORDER) {
32
                /* draw 1-line black border around window*/
33
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOWFRAME));
34
                GrRect(id, gc, x, y, w, h);
35
                x += 1; y += 1; w -= 2; h -= 2;
36
        }
37
 
38
        if (!(props & GR_WM_PROPS_CAPTION))
39
                goto out;
40
 
41
        /* fill caption*/
42
        GrSetGCForeground(gc,
43
                GrGetSysColor(active? GR_COLOR_ACTIVECAPTION:
44
                        GR_COLOR_INACTIVECAPTION));
45
        GrFillRect(id, gc, x, y, w, CYCAPTION);
46
 
47
        /* draw caption text*/
48
        if (title) {
49
                GrSetGCForeground(gc,
50
                        GrGetSysColor(active? GR_COLOR_ACTIVECAPTIONTEXT:
51
                                GR_COLOR_INACTIVECAPTIONTEXT));
52
                GrSetGCUseBackground(gc, GR_FALSE);
53
                fontid = GrCreateFont(GR_FONT_GUI_VAR, 0, NULL);
54
                GrSetGCFont(gc, fontid);
55
                GrText(id, gc, x+4, y-1, title, -1, GR_TFASCII|GR_TFTOP);
56
                GrDestroyFont(fontid);
57
        }
58
        y += CYCAPTION;
59
 
60
        /* draw one line under caption*/
61
        if (props & GR_WM_PROPS_APPFRAME) {
62
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
63
                GrLine(id, gc, x, y, x+w-1, y);
64
        }
65
 
66
        if (props & GR_WM_PROPS_CLOSEBOX) {
67
                /* draw close box*/
68
                r.x = x + w - CXCLOSEBOX - 2;
69
                r.y = y - CYCAPTION + 2;
70
                r.width = CXCLOSEBOX;
71
                r.height = CYCLOSEBOX;
72
 
73
                nxDraw3dBox(id, r.x, r.y, r.width, r.height,
74
                        GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
75
                        GrGetSysColor(GR_COLOR_WINDOWFRAME));
76
                nxInflateRect(&r, -1, -1);
77
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
78
                GrFillRect(id, gc, r.x, r.y, r.width, r.height);
79
 
80
                nxInflateRect(&r, -1, -1);
81
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_BTNTEXT));
82
                GrLine(id, gc, r.x, r.y, r.x+r.width-1, r.y+r.height-1);
83
                GrLine(id, gc, r.x, r.y+r.height-1, r.x+r.width-1, r.y);
84
        }
85
 
86
#if 0
87
        /* fill in client area*/
88
        y++;
89
        h -= CYCAPTION+1;
90
        GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
91
        GrFillRect(id, gc, x, y, w, h);
92
#endif
93
 
94
out:
95
        GrDestroyGC(gc);
96
}
97
 
98
/*
99
 * Enlarge/decrease the size of a rectangle
100
 */
101
void
102
nxInflateRect(GR_RECT *prc, GR_SIZE dx, GR_SIZE dy)
103
{
104
        prc->x -= dx;
105
        prc->y -= dy;
106
        prc->width += dx * 2;
107
        prc->height += dy * 2;
108
}
109
 
110
/*
111
 * nxDraw3dShadow
112
 *      NOINDENT_BLACK  T=white, B=black
113
 *      NOINDENT_GRAY   T=white, B=dkgray
114
 *      INDENT_BLACK    T=black, B=white
115
 *      INDENT_GRAY             T=dkgray, B=white
116
 *
117
 *      TTTTTTTTTTTTTT
118
 *      T             B
119
 *      T             B
120
 *       BBBBBBBBBBBBBB
121
 */
122
void
123
nxDraw3dShadow(GR_DRAW_ID id,int x,int y,int w,int h,GR_COLOR crTop,
124
        GR_COLOR crBottom)
125
{
126
        GR_GC_ID        gc = GrNewGC();
127
 
128
        GrSetGCForeground(gc, crTop);
129
        /*MoveToEx( hDC, x, y+h-2, NULL);*/
130
        /*LineTo( hDC, x, y);*/                         /* left side*/
131
        GrLine(id, gc, x, y+h-2, x, y);                 /* left*/
132
        /*LineTo( hDC, x+w-1, y);*/                     /* top side*/
133
        GrLine(id, gc, x, y, x+w-2, y);                 /* top*/
134
 
135
        GrSetGCForeground(gc, crBottom);
136
        /*MoveToEx( hDC, x+w-1, y+1, NULL);*/
137
        /*LineTo( hDC, x+w-1, y+h-1);*/                 /* right side*/
138
        GrLine(id, gc, x+w-1, y+1, x+w-1, y+h-2);       /* right*/
139
        /*LineTo( hDC, x, y+h-1);*/                     /* bottom side*/
140
        GrLine(id, gc, x+w-1, y+h-1, x, y+h-1);         /* bottom*/
141
 
142
        GrDestroyGC(gc);
143
}
144
 
145
/*
146
 * nxDraw3dBox
147
 *
148
 *      TTTTTTTTTTTTTTB
149
 *      T             B
150
 *      T             B
151
 *      BBBBBBBBBBBBBBB
152
 */
153
void
154
nxDraw3dBox(GR_WINDOW_ID id,int x,int y,int w,int h,GR_COLOR crTop,
155
        GR_COLOR crBottom)
156
{
157
        GR_GC_ID        gc = GrNewGC();
158
 
159
        GrSetGCForeground(gc, crTop);
160
        /*MoveToEx( hDC, x, y+h-2, NULL);*/
161
        /*LineTo( hDC, x, y);*/                         /* left side*/
162
        GrLine(id, gc, x, y+h-2, x, y+1);               /* left*/
163
        /*MoveToEx( hDC, x, y, NULL);*/
164
        /*LineTo( hDC, x+w-1, y);*/                     /* top side*/
165
        GrLine(id, gc, x, y, x+w-2, y);                 /* top*/
166
 
167
        GrSetGCForeground(gc, crBottom);
168
        GrLine(id, gc, x+w-1, y, x+w-1, y+h-2);         /* right*/
169
        /*MoveToEx( hDC, x+w-1, y, NULL);*/
170
        /*LineTo( hDC, x+w-1, y+h-1);*/                 /* right side*/
171
        GrLine(id, gc, x+w-1, y+h-1, x, y+h-1);         /* bottom*/
172
        /*LineTo( hDC, x-1, y+h-1);*/                   /* bottom side*/
173
 
174
        GrDestroyGC(gc);
175
}
176
 
177
/*
178
 * Draw 2 line deep 3d inset
179
 */
180
void
181
nxDraw3dInset(GR_DRAW_ID id,int x,int y,int w,int h)
182
{
183
        nxDraw3dBox(id, x, y, w, h,
184
                GrGetSysColor(GR_COLOR_BTNSHADOW),
185
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT));
186
        ++x; ++y; w -= 2; h -= 2;
187
        nxDraw3dBox(id, x, y, w, h,
188
                GrGetSysColor(GR_COLOR_WINDOWFRAME),
189
                GrGetSysColor(GR_COLOR_3DLIGHT));
190
}
191
 
192
/*
193
 * Draw 2 line deep 3d outset
194
 */
195
void
196
nxDraw3dOutset(GR_DRAW_ID id,int x,int y,int w,int h)
197
{
198
        nxDraw3dBox(id, x, y, w, h,
199
                GrGetSysColor(GR_COLOR_3DLIGHT),
200
                GrGetSysColor(GR_COLOR_WINDOWFRAME));
201
        ++x; ++y; w -= 2; h -= 2;
202
        nxDraw3dBox(id, x, y, w, h,
203
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
204
                GrGetSysColor(GR_COLOR_BTNSHADOW));
205
}
206
 
207
/*
208
 * Draw 1 line pushed down rectangle
209
 */
210
void
211
nxDraw3dPushDown(GR_DRAW_ID id, int x, int y, int w, int h)
212
{
213
        nxDraw3dBox(id, x, y, w, h, GrGetSysColor(GR_COLOR_BTNSHADOW),
214
                GrGetSysColor(GR_COLOR_BTNSHADOW));
215
}
216
 
217
/*
218
 * Draw either 3d up or down depending on state
219
 */
220
void
221
nxDraw3dUpDownState(GR_DRAW_ID id, int x, int y, int w, int h, GR_BOOL fDown)
222
{
223
        if (fDown)
224
                nxDraw3dPushDown(id, x, y, w, h);
225
        else nxDraw3dOutset(id, x, y, w, h);
226
}
227
 
228
#if 0
229
void
230
nxDraw3dUpFrame(GR_DRAW_ID id, int l, int t, int r, int b)
231
{
232
        RECT    rc;
233
        HBRUSH  hbr;
234
 
235
        SetRect(&rc, l, t, r, b);
236
        nxDraw3dBox(hDC, rc.left, rc.top,
237
                rc.right-rc.left, rc.bottom-rc.top,
238
                GrGetSysColor(GR_COLOR_3DLIGHT),
239
                GrGetSysColor(GR_COLOR_WINDOWFRAME));
240
        nxInflateRect(&rc, -1, -1);
241
        nxDraw3dBox(hDC, rc.left, rc.top,
242
                rc.right-rc.left, rc.bottom-rc.top,
243
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
244
                GrGetSysColor(GR_COLOR_BTNSHADOW));
245
        nxInflateRect(&rc, -1, -1);
246
 
247
        hbr = CreateSolidBrush(GrGetSysColor(GR_COLOR_APPWINDOW));
248
        FillRect(hDC, &rc, hbr);
249
        DeleteObject(hbr);
250
}
251
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.