Debian Codegraph @

libSoXt/src/mixedMode/SoXtUIRegion.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Author(s) : Alain Dumesny
46 |
47 |
48 ______________ S I L I C O N G R A P H I C S I N C . ____________
49 _______________________________________________________________________
50 */
51
52 #include "_SoXtUIRegion.h"
53 #include <GL/gl.h>
54
55 // ??? doing a GL_LINE_LOOP seems to be missing the top right
56 // ??? pixel due to subpixel == TRUE in openGL.
57 #define RECT(x1, y1, x2, y2) \
58 glBegin(GL_LINE_STRIP); \
59 glVertex2s(x2, y2); glVertex2s(x1, y2); \
60 glVertex2s(x1, y1); glVertex2s(x2, y1); \
61 glVertex2s(x2, y2+1); \
62 glEnd();
63
64 void SoDrawDownUIBorders(short x1, short y1, short x2, short y2, SbBool blackLast)
65 {
66 DARK1_UI_COLOR;
67 glBegin(GL_LINE_STRIP);
68 glVertex2s(x1, y1+1); glVertex2s(x1, y2); glVertex2s(x2+1, y2);
69 glEnd();
70 LIGHT1_UI_COLOR;
71 glBegin(GL_LINE_STRIP);
72 glVertex2s(x1, y1); glVertex2s(x2, y1); glVertex2s(x2, y2);
73 glEnd();
74
75 x1++; y1++; x2--; y2--;
76 DARK2_UI_COLOR;
77 glBegin(GL_LINE_STRIP);
78 glVertex2s(x1, y1+1); glVertex2s(x1, y2); glVertex2s(x2+1, y2);
79 glEnd();
80 WHITE_UI_COLOR;
81 glBegin(GL_LINE_STRIP);
82 glVertex2s(x1, y1); glVertex2s(x2, y1); glVertex2s(x2, y2);
83 glEnd();
84
85 x1++; y1++; x2--; y2--;
86 if (blackLast) {
87 BLACK_UI_COLOR;
88 RECT(x1, y1, x2, y2);
89 }
90 else {
91 DARK3_UI_COLOR;
92 glBegin(GL_LINE_STRIP);
93 glVertex2s(x1, y1+1); glVertex2s(x1, y2); glVertex2s(x2+1, y2);
94 glEnd();
95 DARK2_UI_COLOR;
96 glBegin(GL_LINE_STRIP);
97 glVertex2s(x1, y1); glVertex2s(x2, y1); glVertex2s(x2, y2);
98 glEnd();
99 }
100 }
101
102
103 void SoDrawDownUIRegion(short x1, short y1, short x2, short y2)
104 {
105 SoDrawDownUIBorders(x1, y1, x2, y2);
106
107 MAIN_UI_COLOR;
108 x1+=UI_THICK; y1+=UI_THICK; x2-=UI_THICK; y2-=UI_THICK;
109 RECT(x1, y1, x2, y2);
110 x1++; y1++; x2--; y2--;
111 RECT(x1, y1, x2, y2);
112 x1++; y1++; x2--; y2--;
113
114 SoDrawDownUIBorders(x1, y1, x2, y2, TRUE);
115 }
116
117
118 void SoDrawThumbUIRegion(short x1, short y1, short x2, short y2)
119 {
120 short v[3][2];
121 short x = (x1 + x2) / 2;
122
123 v[0][0] = x1;
124 v[0][1] = v[2][1] = y1;
125 v[1][0] = x;
126 v[1][1] = y2;
127 v[2][0] = x2;
128
129 MAIN_UI_COLOR;
130 glBegin(GL_POLYGON);
131 glVertex2sv(v[0]);
132 glVertex2sv(v[1]);
133 glVertex2sv(v[2]);
134 glEnd();
135
136 glBegin(GL_LINES);
137
138 BLACK_UI_COLOR;
139 glVertex2s(x1, y1); glVertex2s(x, y2);
140 DARK3_UI_COLOR;
141 glVertex2s(x, y2); glVertex2s(x2, y1);
142 glVertex2s(x2, y1); glVertex2s(x1+1, y1);
143
144 x1++; y1++; x2--; y2--;
145 WHITE_UI_COLOR;
146 glVertex2s(x1, y1); glVertex2s(x, y2);
147 DARK2_UI_COLOR;
148 glVertex2s(x, y2); glVertex2s(x2, y1);
149 DARK1_UI_COLOR;
150 glVertex2s(x2, y1); glVertex2s(x1+1, y1);
151
152 x1++; y1++; x2--; y2--;
153 WHITE_UI_COLOR;
154 glVertex2s(x1, y1); glVertex2s(x, y2);
155 DARK2_UI_COLOR;
156 glVertex2s(x, y2); glVertex2s(x2, y1);
157
158 glEnd();
159 }
160