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

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [mwin/] [winlib/] [draw3d.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
#include "windows.h"
2
#include "wintools.h"
3
/*
4
 * WIN Draw Library
5
 *      Draw3dShadow - draws a shadow with bottom-left and top-right missing
6
 *      Draw3dBox - draws a complete shadow
7
 *      Draw3dInset - draw a 2 line 3d inset
8
 *      Draw3dOutset - draw a 2 line 3d outset
9
 */
10
 
11
/*
12
 * Draw3dShadow
13
 *      NOINDENT_BLACK  T=white, B=black
14
 *      NOINDENT_GRAY   T=white, B=dkgray
15
 *      INDENT_BLACK    T=black, B=white
16
 *      INDENT_GRAY             T=dkgray, B=white
17
 *
18
 *      TTTTTTTTTTTTTT
19
 *      T             B
20
 *      T             B
21
 *       BBBBBBBBBBBBBB
22
 */
23
void WINAPI
24
Draw3dShadow(HDC hDC,int x,int y,int w,int h,COLORREF crTop,COLORREF crBottom)
25
{
26
        HPEN    hPenTop, hPenBottom, holdPen;
27
 
28
        hPenTop = CreatePen( PS_SOLID, 1, crTop);
29
        hPenBottom = CreatePen( PS_SOLID, 1, crBottom);
30
        holdPen = SelectObject( hDC, hPenTop);
31
        MoveToEx( hDC, x, y+h-2, NULL);
32
        LineTo( hDC, x, y);                             /* left side*/
33
        LineTo( hDC, x+w-1, y);                         /* top side*/
34
 
35
        SelectObject( hDC, hPenBottom);
36
        MoveToEx( hDC, x+w-1, y+1, NULL);
37
        LineTo( hDC, x+w-1, y+h-1);                     /* right side*/
38
        LineTo( hDC, x, y+h-1);                         /* bottom side*/
39
 
40
        SelectObject( hDC, holdPen);
41
        DeleteObject( hPenTop);
42
        DeleteObject( hPenBottom);
43
}
44
 
45
/*
46
 * Draw3dBox
47
 *
48
 *      TTTTTTTTTTTTTTB
49
 *      T             B
50
 *      T             B
51
 *      BBBBBBBBBBBBBBB
52
 */
53
void WINAPI
54
Draw3dBox(HDC hDC,int x,int y,int w,int h,COLORREF crTop,COLORREF crBottom)
55
{
56
        HPEN            hPenTop, hPenBottom, holdPen;
57
 
58
        hPenTop = CreatePen( PS_SOLID, 1, crTop);
59
        hPenBottom = CreatePen( PS_SOLID, 1, crBottom);
60
        holdPen = SelectObject( hDC, hPenTop);
61
        MoveToEx( hDC, x, y+h-2, NULL);
62
        LineTo( hDC, x, y);                             /* left side*/
63
        MoveToEx( hDC, x, y, NULL);
64
        LineTo( hDC, x+w-1, y);                         /* top side*/
65
 
66
        SelectObject( hDC, hPenBottom);
67
        MoveToEx( hDC, x+w-1, y, NULL);
68
        LineTo( hDC, x+w-1, y+h-1);                     /* right side*/
69
        LineTo( hDC, x-1, y+h-1);                       /* bottom side*/
70
 
71
        SelectObject( hDC, holdPen);
72
        DeleteObject( hPenTop);
73
        DeleteObject( hPenBottom);
74
}
75
 
76
/*
77
 * Draw 2 line deep 3d inset
78
 */
79
void WINAPI
80
Draw3dInset(HDC hDC,int x,int y,int w,int h)
81
{
82
        Draw3dBox(hDC, x, y, w, h,
83
                GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT));
84
        ++x; ++y; w -= 2; h -= 2;
85
        Draw3dBox(hDC, x, y, w, h,
86
                GetSysColor(COLOR_WINDOWFRAME), GetSysColor(COLOR_3DLIGHT));
87
}
88
 
89
/*
90
 * Draw 2 line deep 3d outset
91
 */
92
void WINAPI
93
Draw3dOutset(HDC hDC,int x,int y,int w,int h)
94
{
95
        Draw3dBox(hDC, x, y, w, h,
96
                GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_WINDOWFRAME));
97
        ++x; ++y; w -= 2; h -= 2;
98
        Draw3dBox(hDC, x, y, w, h,
99
                GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW));
100
}
101
 
102
/*
103
 * Draw 1 line pushed down rectangle
104
 */
105
void WINAPI
106
Draw3dPushDown(HDC hDC, int x, int y, int w, int h)
107
{
108
        Draw3dBox(hDC, x, y, w, h, GetSysColor(COLOR_BTNSHADOW),
109
                GetSysColor(COLOR_BTNSHADOW));
110
}
111
 
112
/*
113
 * Draw either 3d up or down depending on state
114
 */
115
void WINAPI
116
Draw3dUpDownState(HDC hDC, int x, int y, int w, int h, BOOL fDown)
117
{
118
        if (fDown)
119
                Draw3dPushDown(hDC, x, y, w, h);
120
        else Draw3dOutset(hDC, x, y, w, h);
121
}
122
 
123
void WINAPI
124
Draw3dUpFrame(HDC hDC, int l, int t, int r, int b)
125
{
126
        RECT    rc;
127
        HBRUSH  hbr;
128
 
129
        SetRect(&rc, l, t, r, b);
130
        Draw3dBox(hDC, rc.left, rc.top,
131
                rc.right-rc.left, rc.bottom-rc.top,
132
                GetSysColor(COLOR_3DLIGHT),
133
                GetSysColor(COLOR_WINDOWFRAME));
134
        InflateRect(&rc, -1, -1);
135
        Draw3dBox(hDC, rc.left, rc.top,
136
                rc.right-rc.left, rc.bottom-rc.top,
137
                GetSysColor(COLOR_BTNHIGHLIGHT),
138
                GetSysColor(COLOR_BTNSHADOW));
139
        InflateRect(&rc, -1, -1);
140
 
141
        hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
142
        FillRect(hDC, &rc, hbr);
143
        DeleteObject(hbr);
144
}

powered by: WebSVN 2.1.0

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