~ctwm/ctwm/trunk

1 by Claude Lecommandeur
CTWM version 1.1
1
/*****************************************************************************/
2
/**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
3
/**                          Salt Lake City, Utah                           **/
4
/**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **/
5
/**                        Cambridge, Massachusetts                         **/
6
/**                                                                         **/
7
/**                           All Rights Reserved                           **/
8
/**                                                                         **/
9
/**    Permission to use, copy, modify, and distribute this software and    **/
10
/**    its documentation  for  any  purpose  and  without  fee is hereby    **/
11
/**    granted, provided that the above copyright notice appear  in  all    **/
12
/**    copies and that both  that  copyright  notice  and  this  permis-    **/
13
/**    sion  notice appear in supporting  documentation,  and  that  the    **/
14
/**    names of Evans & Sutherland and M.I.T. not be used in advertising    **/
15
/**    in publicity pertaining to distribution of the  software  without    **/
16
/**    specific, written prior permission.                                  **/
17
/**                                                                         **/
18
/**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **/
19
/**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
20
/**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **/
21
/**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
22
/**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
23
/**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
24
/**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
25
/**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
26
/*****************************************************************************/
304.1.2 by Matthew Fuller
Run 'make indent' to reindent the world.
27
/*
11 by Claude Lecommandeur
CTWM version 3.2p1
28
 *  [ ctwm ]
29
 *
30
 *  Copyright 1992 Claude Lecommandeur.
304.1.2 by Matthew Fuller
Run 'make indent' to reindent the world.
31
 *
11 by Claude Lecommandeur
CTWM version 3.2p1
32
 * Permission to use, copy, modify  and distribute this software  [ctwm] and
33
 * its documentation for any purpose is hereby granted without fee, provided
34
 * that the above  copyright notice appear  in all copies and that both that
35
 * copyright notice and this permission notice appear in supporting documen-
36
 * tation, and that the name of  Claude Lecommandeur not be used in adverti-
37
 * sing or  publicity  pertaining to  distribution of  the software  without
38
 * specific, written prior permission. Claude Lecommandeur make no represen-
39
 * tations  about the suitability  of this software  for any purpose.  It is
40
 * provided "as is" without express or implied warranty.
41
 *
42
 * Claude Lecommandeur DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
43
 * INCLUDING ALL  IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS.  IN NO
44
 * EVENT SHALL  Claude Lecommandeur  BE LIABLE FOR ANY SPECIAL,  INDIRECT OR
45
 * CONSEQUENTIAL  DAMAGES OR ANY  DAMAGES WHATSOEVER  RESULTING FROM LOSS OF
46
 * USE, DATA  OR PROFITS,  WHETHER IN AN ACTION  OF CONTRACT,  NEGLIGENCE OR
47
 * OTHER  TORTIOUS ACTION,  ARISING OUT OF OR IN  CONNECTION WITH THE USE OR
48
 * PERFORMANCE OF THIS SOFTWARE.
49
 *
50
 * Author:  Claude Lecommandeur [ lecom@sic.epfl.ch ][ April 1992 ]
51
 */
1 by Claude Lecommandeur
CTWM version 1.1
52
53
54
/**********************************************************************
55
 *
56
 * $XConsortium: gc.c,v 1.22 91/01/09 17:13:12 rws Exp $
57
 *
58
 * Open the fonts and create the GCs
59
 *
60
 * 31-Mar-88 Tom LaStrange        Initial Version.
61
 *
62
 * Do the necessary modification to be integrated in ctwm.
63
 * Can no longer be used for the standard twm.
64
 *
65
 * 22-April-92 Claude Lecommandeur.
66
 *
67
 *
68
 **********************************************************************/
69
395.1.1 by Matthew Fuller
Move ctwm.h to always be included first.
70
#include "ctwm.h"
71
1 by Claude Lecommandeur
CTWM version 1.1
72
#include <stdio.h>
340.1.1 by Matthew Fuller
Rearrange includes to be in what we'll call the Proper Order.
73
254.1.3 by Matthew Fuller
Both Berkeley byacc back to at least 1993 and bison to at least 1996
74
#include "gram.tab.h"
1 by Claude Lecommandeur
CTWM version 1.1
75
#include "screen.h"
93 by Richard Levitte
- Convert all functions to use proper prototypes.
76
#include "gc.h"
1 by Claude Lecommandeur
CTWM version 1.1
77
78
/***********************************************************************
79
 *
80
 *  Procedure:
304.1.2 by Matthew Fuller
Run 'make indent' to reindent the world.
81
 *      CreateGCs - open fonts and create all the needed GC's.  I only
82
 *                  want to do this once, hence the first_time flag.
1 by Claude Lecommandeur
CTWM version 1.1
83
 *
84
 ***********************************************************************
85
 */
86
93 by Richard Levitte
- Convert all functions to use proper prototypes.
87
void CreateGCs(void)
1 by Claude Lecommandeur
CTWM version 1.1
88
{
304.1.2 by Matthew Fuller
Run 'make indent' to reindent the world.
89
	static ScreenInfo *prevScr = NULL;
90
	XGCValues       gcv;
91
	unsigned long   gcm;
92
	static unsigned char greypattern [] = {0x0f, 0x05, 0x0f, 0x0a};
93
	Pixmap        greypixmap;
94
	static char dashlist [2] = {1, 1};
95
96
	if(!Scr->FirstTime || prevScr == Scr) {
97
		return;
98
	}
99
100
	prevScr = Scr;
101
102
	/* create GC's */
103
104
	gcm = 0;
105
	gcm |= GCFunction;
106
	gcv.function = GXxor;
107
	gcm |= GCLineWidth;
108
	gcv.line_width = 0;
109
	gcm |= GCForeground;
110
	gcv.foreground = Scr->XORvalue;
111
	gcm |= GCSubwindowMode;
112
	gcv.subwindow_mode = IncludeInferiors;
113
114
	Scr->DrawGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
115
116
	gcm = 0;
117
	gcm |= GCForeground;
118
	gcv.foreground = Scr->MenuC.fore;
119
	gcm |= GCBackground;
120
	gcv.background = Scr->MenuC.back;
121
122
	Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
123
124
	gcm = 0;
125
	gcm |= GCPlaneMask;
126
	gcv.plane_mask = AllPlanes;
127
	/*
128
	 * Prevent GraphicsExpose and NoExpose events.  We'd only get NoExpose
129
	 * events anyway;  they cause BadWindow errors from XGetWindowAttributes
130
	 * call in FindScreenInfo (events.c) (since drawable is a pixmap).
131
	 */
132
	gcm |= GCGraphicsExposures;
133
	gcv.graphics_exposures = False;
134
	gcm |= GCLineWidth;
135
	gcv.line_width = 0;
136
137
	Scr->NormalGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
138
139
	greypixmap = XCreatePixmapFromBitmapData(dpy, Scr->Root,
140
	                (char *) greypattern, 4, 4, 1, 0, 1);
141
142
	if(Scr->Monochrome != COLOR) {
143
		gcm  = 0;
144
		gcm |= GCStipple;
145
		gcv.stipple    = greypixmap;
146
		gcm |= GCFillStyle;
147
		gcv.fill_style = FillOpaqueStippled;
148
		gcm |= GCForeground;
149
		gcv.foreground = Scr->Black;
150
		gcm |= GCBackground;
151
		gcv.background = Scr->White;
152
		Scr->BorderGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
153
		XSetDashes(dpy, Scr->BorderGC, 1, dashlist, 2);
154
	}
155
	else if(Scr->BeNiceToColormap) {
156
		gcm  = 0;
157
		gcm |= GCLineStyle;
158
		gcv.line_style = LineDoubleDash;
159
		Scr->BorderGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
160
		XSetDashes(dpy, Scr->BorderGC, 0, dashlist, 2);
161
	}
162
	else {
163
		Scr->BorderGC = XCreateGC(dpy, Scr->Root, 0, (XGCValues *) 0);
164
	}
1 by Claude Lecommandeur
CTWM version 1.1
165
}